home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / utility / alert10.zip / ALERT.C < prev    next >
C/C++ Source or Header  |  1994-03-03  |  3KB  |  136 lines

  1. #include <graphics.h>
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include <dos.h>
  5. #include <time.h>
  6. #include <stdlib.h>
  7. #include "alert.h"
  8.  
  9.  
  10.  
  11. void main( int argc, char **argv )
  12. {
  13.  
  14.    
  15.    clock_t t_start,
  16.        t_end,
  17.        t_tot;
  18.    long hrs,
  19.     min,
  20.     sec;
  21.  
  22.       SoundFlag = ON;
  23.  
  24.       if( argc > 1 )
  25.      if( *argv[1] == 's' )
  26.          SoundFlag = OFF;
  27.  
  28.  
  29.       t_start = clock() / CLK_TCK;
  30.  
  31.       graphics_setup( SETUP_COLOR );
  32.  
  33.       while( !( kbhit() && getch() == EXITVALUE ) )  // Press EXITVALUE (in alert.h file) to exit.
  34.      FlashCycle();
  35.  
  36.       closegraph();
  37.  
  38.       t_end = clock() / CLK_TCK;
  39.  
  40.       t_tot = t_end- t_start;
  41.       hrs = t_tot / 3600;
  42.       t_tot = t_tot - ( hrs * 3600 );
  43.       min = t_tot / 60;
  44.       t_tot = t_tot - ( min * 60 );
  45.       sec = t_tot;
  46.  
  47.       textcolor( LIGHTBLUE );
  48.       cprintf( "\n\nALERT has been running for %ld hour(s), %ld minute(s), %ld second(s).", hrs, min, sec );      
  49.  
  50. }
  51.  
  52.  
  53. /*************************************************************************/
  54. /*                    GENERIC VGA GRAPHICS SETUP                         */
  55. /*************************************************************************/
  56.  
  57. void graphics_setup( int background_color )
  58. {
  59.    int grdriver = VGA,
  60.        grmode = VGAHI;
  61.  
  62.        registerfarbgidriver( EGAVGA_driver_far );
  63.        registerfarbgifont( triplex_font_far );
  64.        initgraph( &grdriver, &grmode, "" );
  65.  
  66.        if( graphresult() )  //Error in opening graphics mode..
  67.           {
  68.           closegraph();
  69.           exit ( GR_ERROR );
  70.           puts( "Error in opening graphics systems!" );
  71.           }
  72.  
  73.        setbkcolor( background_color );
  74.        setcolor( PIXEL_COLOR );
  75.  
  76.        return;
  77.  
  78. }
  79.  
  80. void write_text( int x_coord, int y_coord, int type_size, char* text )
  81. {
  82.       settextstyle( TRIPLEX_FONT, HORIZ_DIR, type_size);
  83.       outtextxy( x_coord, y_coord, text );
  84.  
  85.       return;
  86. }
  87.  
  88. void FlashCycle()
  89. {
  90.  
  91.     static char *txt1,
  92.         *txt2;
  93.    int y_ht,
  94.        line1color,
  95.        count = -1;
  96.  
  97.       randomize();
  98.  
  99.       txt1 = Msg1;
  100.       txt2 = Msg2;
  101.  
  102.       switch ( random ( RANDOM ) )
  103.      {
  104.      case 0:
  105.         setbkcolor( LIGHTBLUE );
  106.         line1color = YELLOW;
  107.         break;
  108.      case 1:
  109.         setbkcolor( WHITE );
  110.         line1color = DARKGRAY;
  111.         break;
  112.      default:
  113.         setbkcolor( YELLOW );
  114.         line1color = RED;
  115.       }
  116.  
  117.       y_ht = random( MAXYHT );
  118.       WRITE_LINE1;
  119.  
  120.       while( !kbhit() && ++count < MAXCYCLECOUNT )
  121.      {
  122.      delay( DELAY ); 
  123.      ERASE_LINE1;
  124.      WRITE_LINE2;
  125.  
  126.      if( random( MAXCYCLECOUNT ) > DIALPHONE && SoundFlag == ON )
  127.         dial();
  128.  
  129.      delay( DELAY );           
  130.      ERASE_LINE2;
  131.      WRITE_LINE1; 
  132.      }
  133.       cleardevice();
  134.  
  135.       return;
  136. }